#ifndef __OLED_H
#define __OLED_H 

#include "systick.h"
#include "gd32f4xx.h"
#include "i2c_soft.h"
#include "i2c_hard.h"
#include <stdio.h>
//#include "bmp.h"

#ifndef u8
#define u8 uint8_t
#endif
#ifndef u16
#define u16 uint16_t
#endif
#ifndef u32
#define u32 uint32_t
#endif

//-----------------OLED端口定义---------------- 

#define WRTTER_ADDR (0x78>>1)
#define OLED_CMD  0	//写命令
#define OLED_DATA 1	//写数据

#define USE_I2C_SOFT 0
#define USE_I2C_HARD 1

#if USE_I2C_SOFT
#define I2C_CONFIG_INIT  i2c_hard_init
#define I2C_SEND_BYTE  i2c_soft_write
#endif 

#if USE_I2C_HARD
#define I2C_CONFIG_INIT  i2c_soft_init
#define I2C_SEND_BYTE    i2c_hard_write
#endif 

void OLED_ClearPoint(u8 x, u8 y);
void OLED_ColorTurn(u8 i);
void OLED_DisplayTurn(u8 i);
//void I2C_Start(void);
//void I2C_Stop(void);
//void I2C_WaitAck(void);
//void Send_Byte(u8 dat);
void OLED_WR_Byte(u8 dat, u8 mode);
void OLED_DisPlay_On(void);
void OLED_DisPlay_Off(void);
void OLED_Refresh(void);
void OLED_Clear(void);
void OLED_DrawPoint(u8 x, u8 y, u8 t);
void OLED_DrawLine(u8 x1, u8 y1, u8 x2, u8 y2, u8 mode);
void OLED_DrawCircle(u8 x, u8 y, u8 r);
void OLED_ShowChar(u8 x, u8 y, u8 chr, u8 size1, u8 mode);
void OLED_ShowChar6x8(u8 x, u8 y, u8 chr, u8 mode);
void OLED_ShowString(u8 x, u8 y, char* chr, u8 size1, u8 mode);
void OLED_ShowNum(u8 x, u8 y, u32 num, u8 len, u8 size1, u8 mode);
void OLED_ShowChinese(u8 x, u8 y, u8 num, u8 size1, u8 mode);
void OLED_ScrollDisplay(u8 num, u8 space, u8 mode);
void OLED_ShowPicture(u8 x, u8 y, u8 sizex, u8 sizey, u8 BMP[], u8 mode);
void OLED_Init(void);

// 测试使用代码
//while(1) {
//    OLED_ShowPicture(0,0,128,64,BMP1,1);
//    OLED_Refresh();
//    delay_1ms(500);
//    OLED_Clear();
//    OLED_ShowChinese(0,0,0,16,1);//中
//    OLED_ShowChinese(18,0,1,16,1);//景
//    OLED_ShowChinese(36,0,2,16,1);//园
//    OLED_ShowChinese(54,0,3,16,1);//电
//    OLED_ShowChinese(72,0,4,16,1);//子
//    OLED_ShowChinese(90,0,5,16,1);//技
//    OLED_ShowChinese(108,0,6,16,1);//术
//    OLED_ShowString(8,16,"ZHONGJINGYUAN",16,1);
//    OLED_ShowString(20,32,"2014/05/01",16,1);
//    OLED_ShowString(0,48,"ASCII:",16,1);
//    OLED_ShowString(63,48,"CODE:",16,1);
//    OLED_ShowChar(48,48,t,16,1);//显示ASCII字符
//    t++;
//    if(t>'~')t=' ';
//    OLED_ShowNum(103,48,t,3,16,1);
//    OLED_Refresh();
//    delay_1ms(500);
//    OLED_Clear();
//    OLED_ShowChinese(0,0,0,16,1);  //16*16 中
//    OLED_ShowChinese(16,0,0,24,1); //24*24 中
//    OLED_ShowChinese(24,20,0,32,1);//32*32 中
//    OLED_ShowChinese(64,0,0,64,1); //64*64 中
//    OLED_Refresh();
//    delay_1ms(500);
//    OLED_Clear();
//    OLED_ShowString(0,0,"ABC",8,1);//6*8 “ABC”
//    OLED_ShowString(0,8,"ABC",12,1);//6*12 “ABC”
//    OLED_ShowString(0,20,"ABC",16,1);//8*16 “ABC”
//    OLED_ShowString(0,36,"ABC",24,1);//12*24 “ABC”
//    OLED_Refresh();
//    delay_1ms(500);
//    OLED_ScrollDisplay(11,4,1);
//}

#endif

